/**
 * Created by zmy on 2018/3/12.
 */
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var pug = require('gulp-pug');
var uglify = require('gulp-uglify');

gulp.task('pug', function () {
   return gulp.src('pug/**/*.pug')
       .pipe(pug())
       .pipe(gulp.dest('build/html'))
});

gulp.task('less', function () {
    return gulp.src('less/**/*.less')
        .pipe(plugins.less())
        .pipe(plugins.minifyCss())
        .pipe(plugins.rename({
            suffix: '.min'
        }))
        .pipe(gulp.dest('build/css'))
});

gulp.task('script', function () {
    gulp.src('js/*.js')
        .pipe(uglify({ mangle: false }))
        .pipe(plugins.rename({
            suffix: '.min'
        }))
        .pipe(gulp.dest('build/js'))
});

gulp.task('watch', function () {
    gulp.watch(['pug/**/*.pug', 'pug/*.pug'], ['pug']);
    gulp.watch(['less/**/*.less', 'less/*.less'], ['less']);
});
